<template>
  <div class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('申请单') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('申请标题') }}</td>
        <td colspan="3">{{ form.actTitle }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('披露对象') }}</td>
        <td>
          <el-select v-model="form.disclosureObject">
            <el-option
              v-for="dict in disclosureObjectOptions"
              :key="dict.dictValue"
              :label="$t(dict.dictLabel)"
              :value="dict.dictValue"
            />
          </el-select>
        </td>

        <td class="tit">{{ $t('披露类型') }}</td>
        <td>
          <el-select v-model="form.disclosureType">
            <el-option
              v-for="dict in disclosureTypeOptions"
              :key="dict.dictValue"
              :label="$t(dict.dictLabel)"
              :value="dict.dictValue"
            />
          </el-select>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('报告期-年') }}</td>
        <td>
          {{ form.reportPeriodYear }}
        </td>

        <td class="tit">{{ $t('报告期-季') }}</td>
        <td>
          <el-select v-model="form.reportPeriodSeason">
            <el-option
              v-for="dict in reportPeriodSeasonOptions"
              :key="dict.dictValue"
              :label="$t(dict.dictLabel)"
              :value="dict.dictValue"
            />
          </el-select>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('报告类型') }}</td>
        <td colspan="3">
          <el-select v-model="form.reportType">
            <el-option
              v-for="(dict, index) in reportTypeOptions"
              :key="index"
              :value="dict.dictValue"
              :label="$t(dict.dictLabel)"
            />
          </el-select>
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('备注') }}</td>
        <td colspan="3">
          {{ form.remark }}
        </td>
      </tr>
    </table>

    <FileView :list.sync="form.fileList" data-type="fund_disclosure" :business-id="autoBusinessId($route.query.id, form)" />

  </div>
</template>

<script>
    import { getFundDisclosure } from '@/api/fund/disclosure/fundDisclosure'

    export default {
        data() {
            return {
                // 披露对象字典
                disclosureObjectOptions: [], // 披露类型字典
                disclosureTypeOptions: [], // 报告期-季字典
                reportPeriodSeasonOptions: [], // 表单参数
                reportTypeOptions: [], // 报告类型字典
                form: {
                  fileList: []
                },
                // 遮罩层
                loading: false,
                // 操作按钮默认不展示
                buttonShow: true,
                // 是否隐藏保存等按钮
                btnHide: false
            }
        },
        created() {
            this.getDicts('fund_disclosure_object').then(response => {
                this.disclosureObjectOptions = response.data
            })
            this.getDicts('fund_disclosure_type').then(response => {
                this.disclosureTypeOptions = response.data
            })
            this.getDicts('fund_disclosure_quarter').then(response => {
                this.reportPeriodSeasonOptions = response.data
            })
            this.getDicts('fund_report_type').then(response => {
              this.reportTypeOptions = response.data
            })
            this.$bus.$emit('async_done')
        },
        methods: {
          // 初始化数据
          init(data) {
              this.loading = true
              if (data != null && data.id !== undefined) {
                  getFundDisclosure(data.id).then(response => {
                      this.form = response.data
                      this.loading = false
                  })
              }
          },

          // 披露类型字典翻译
          disclosureTypeFormat(disclosureType) {
            return this.selectDictLabel(this.disclosureTypeOptions, disclosureType)
          },
          // 报告类型字典翻译
          reportTypeFormat(reportType) {
            return this.selectDictLabel(this.reportTypeOptions, reportType)
          }

        }

    }
</script>
